import { instance, instance2 } from '../request'

const remoteRequest = instance2

/**
 * 获取登录验证码
 * @returns
 */
export const verificationCodeApi = (): PromiseRes<string> =>
  remoteRequest.post('/api/verificationCode')

/**
 * 登录
 * @param account 账号
 * @param password 密码
 * @param code 验证码
 * @returns
 */
export const loginApi = (
  account: string,
  password: string,
  code: string
): PromiseRes<string> =>
  remoteRequest.post(`/api/login?code=${code}`, { account, password })

/**
 * 获取用户信息
 * @returns
 */
export const getUserInfoApi = (): PromiseRes<UserInfoItf> =>
  remoteRequest.get('/user/info')

/**
 * 获取用户可以访问的系统页面路由
 * @param systemName 系统名称
 * @returns
 */
export const getUserAccessRoutesApi = (
  systemName: string
): PromiseRes<RouteItf[]> =>
  remoteRequest.get(`/user/getAccessRoutes?systemName=${systemName}`)

/**
 * 用户退出
 * @returns
 */
export const logoutApi = () => instance.post('/remote/user/logout')
